package com.yanjiali.controller;

import com.yanjiali.model.R;
import com.yanjiali.model.req.UpdateSettingContentReq;
import com.yanjiali.model.resp.GetSettingJsonResp;
import com.yanjiali.model.resp.UpdateSettingContentResp;
import com.yanjiali.service.SettingContentService;
import com.yanjiali.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.yanjiali.controller
 * @Author: yanjiali
 * @Created: 2025/4/30 15:02
 */
@Api(tags = "设置控制器")
@RestController
@RequestMapping("/v1/settings")
public class SettingController {

    @Autowired
    private SettingService settingService;

    @Autowired
    private SettingContentService settingContentService;

    @GetMapping("/getSettingJson")
    @ApiOperation("获取对应设置的json结果对象")
    public R<GetSettingJsonResp> getSettingJson() {
        return settingService.getSettingJson();
    }

    @PostMapping("/updateSettingContent")
    @ApiOperation("修改对应设置内容")
    public R<UpdateSettingContentResp> updateSettingContent(@RequestBody UpdateSettingContentReq updateSettingContentReq) {
        return settingContentService.updateSettingContent(updateSettingContentReq);
    }

    @GetMapping("/getSettingContentIsOpenByName")
    @ApiOperation("通过设置名称获取设置是否开启")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "对应设置内容名称")
    })
    public R getSettingContentIsOpenByName(@RequestParam String name) {
        return settingContentService.getSettingContentIsOpenByName(name);
    }
}
